Assembly Language
This page describes how gcc passes arguments, which is required when accessing those arguments from inside a piece of assembly.
Here's an example of how gcc compiled a function
00c06950 <zobbo>:
int __attribute__ ((noinline)) zobbo(uint8_t drive_num, uint32_t block_num, uint8_t *buffer) {
drive_num++;
if (drive_num == 42) {
c06950: 0c2f 0029 0007 cmpib #41,%sp@(7)
c06956: 671e beqs c06976 <zobbo+0x26>
return NOT_OK;
}
block_num--;
if (block_num == 99) {
c06958: 7064 moveq #100,%d0
c0695a: b0af 0008 cmpl %sp@(8),%d0
c0695e: 670e beqs c0696e <zobbo+0x1e>
errno = 99;
return NOT_OK;
}
if (*buffer == '!') {
c06960: 206f 000c moveal %sp@(12),%a0
c06964: 0c10 0021 cmpib #33,%a0@
c06968: 57c0 seq %d0
c0696a: 49c0 extbl %d0
return NOT_OK;
}
return OK;
}
c0696c: 4e75 rts
errno = 99;
c0696e: 7063 moveq #99,%d0
c06970: 23c0 0000 1160 movel %d0,1160 <errno>
return NOT_OK;
c06976: 70ff moveq #-1,%d0
}
c06978: 4e75 rts